package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Rejected;
import com.dragon.repository.entity.RejectedProduct;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RejectedDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "退货名称")
    private String name;

    @ApiModelProperty(value = "生产id")
    private Integer produceId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "退货编号")
    private String rejectedCode;

    @ApiModelProperty(value = "审核状态：0待审核1审核通过2审核不通过3作废4删除")
    private Integer status;

    @ApiModelProperty(value = "退货完成状态：0未完成1完成")
    private Integer rejectedState;

    @ApiModelProperty(value = "发货状态：0 未发货，1已发货，2，发货完成")
    private Integer deliverStatus;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "删除标识 0否 1是")    private Integer deleted;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss ",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "用户名称")
    private String username;

    @ApiModelProperty(value = "退货产品")
    private List<RejectedProductDTO> rejectedProductDTOS;

    @ApiModelProperty(value = "审批流程")
    private List<WorkflowJson> workflowJsonList;


    public RejectedDTO() {}

    public RejectedDTO(Rejected entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static RejectedDTO convert(Rejected entity) {
        return new RejectedDTO(entity);
    }

    public static List<RejectedDTO> convertList(List<Rejected> list) {
        List<RejectedDTO> resultList = new ArrayList<>();
        for (Rejected entity : list) {
            resultList.add(new RejectedDTO(entity));
        }
        return resultList;
    }}
